package com.oa.dao;

import com.oa.pojo.User;
import com.oa.utils.MybatisUtils;

public class UserDao {
    /**
     * 按用户名查找用户
     * @param username
     * @return 返回null表示用户不存在
     */
    public User selectByUsername(String username){
        return (User) MybatisUtils.executeQuery(sqlSession -> sqlSession.selectOne("usermapper.selectByUsername", username));
    }

    public void insert(User user) {
        MybatisUtils.executeUpdate(sqlSession -> sqlSession.insert("usermapper.insert", user));
    }
}
